Pull changes from your Git repository on Bitbucket Cloud

Next on your list of space station administrator activities, you need a file with more details about your locations. Since you don't have many locations at the moment, you are going to add them right from Bitbucket.

Step 1. Create a file in Bitbucket

To add your new locations file, do the following:

  1. From your BitbucketStationLocations repository, click Source to open the source directory.
    Notice you only have one file, locations.txt, in your directory.

Image displaying the repository source page
  • A. Source page: Click the link to open this page.

  • B. Branch selection: Pick the branch you want to view. 

  • C. More options button: Click to open a menu with more options, such as 'Add file'.

  • D. Source file area: View the directory of files in Bitbucket. 

2. From the Source page, click the More options button in the top right corner and select Add file from the menu. The More options button only appears after you have added at least one file to the repository.

A page for creating the new file opens, as shown in the following image.

image of new file
  • A. Branch with new file: Change if you want to add file to a different branch.

  • B. New file area: Add content for your new file here. 

3. Enter stationlocations in the filename field.

4. Select HTML from the Syntax mode list.
5. Add the following HTML code into the text box:

1 2 3 4 5 6 <p>Bitbucket has the following space stations:</p> <p> <b>Earth's Moon</b><br> Headquarters </p>

6. Click Commit. The Commit message field appears with the message: stationlocations created online with Bitbucket.

7. Click Commit under the message field.

You now have a new file in Bitbucket! You are taken to a page with details of the commit, where you can see the change you just made:

image of the new file committed

If you want to see a list of the commits you've made so far, click Commits in the sidebar.

Step 2. Pull changes from a remote repository

Now we need to get that new file into your local repository. The process is pretty straight forward, basically just the reverse of the push you used to get the  locations.txt  file into Bitbucket.

To pull the file into your local repository, do the following:

  1. Open your terminal window and navigate to the top level of your local repository.

    macOS / Linux / Git Bash
    $ cd ~/repos/bitbucketstationlocations/

    Windows Command Prompt
    $ cd repos/bitbucketstationlocations/

  2. Enter the  git pull --all  command to pull all the changes from Bitbucket. (In more complex branching workflows, pulling and merging all changes might not be appropriate .)  Enter your Bitbucket password when asked for it. Your terminal should look similar to the following:

    1 2 3 4 5 6 7 8 9 10 11 12 13 $ git pull --all Fetching origin remote: Counting objects: 3, done. remote: Compressing objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (3/3), done. From https://bitbucket.org/emmap1/bitbucketstationlocations fe5a280..fcbeeb0 master -> origin/master Updating fe5a280..fcbeeb0 Fast-forward stationlocations | 5 ++++++++++++++ 1 file changed, 5 insertions(+) create mode 100644 stationlocations

    The  git pull command merges the file from your remote repository (Bitbucket) into your local repository with a single command.

  3. Navigate to your repository folder on your local system and you'll see the file you just added.

Fantastic! With the addition of the two files about your space station location, you have performed the basic Git workflow (clone, add, commit, push, and pull) between Bitbucket and your local system.

Next

Still need help?

The Atlassian Community is here for you.